#
# This is a makefile for lab 1.
#

CC = g++
LINK_OPTION = -lz
COMPILE_OPTION = -g -Wall -Wfatal-errors -fverbose-asm -g3 -g -fstack-check -DDEBUG -gdwarf-2

all: clean sim

clean:
	rm -f *.o *.out sim

case1:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=0 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=1 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/case1.pzip\" --output_file=\"./lab3_test_cases/kunal_case1.out\" > ./lab3_test_cases/kunal_case1-dump.txt; cat lab3_test_cases/kunal_case1-dump.txt; cat lab3_test_cases/kunal_case1.out; echo \"-------------------------\" ;cat lab3_test_cases/case1.out;"

case2:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=0 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=1 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/case2.pzip\" --output_file=\"./lab3_test_cases/kunal_case2.out\" > ./lab3_test_cases/kunal_case2-dump.txt; cat lab3_test_cases/kunal_case2-dump.txt; cat lab3_test_cases/kunal_case2.out; echo \"-------------------------\" ;cat lab3_test_cases/case2.out;"
case3:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=0 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=1 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/case3.pzip\" --output_file=\"./lab3_test_cases/kunal_case3.out\" > ./lab3_test_cases/kunal_case3-dump.txt; cat lab3_test_cases/kunal_case3-dump.txt; cat lab3_test_cases/kunal_case3.out; echo \"-------------------------\" ;cat lab3_test_cases/case3.out;"

case4:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=0 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=1 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/case4.pzip\" --output_file=\"./lab3_test_cases/kunal_case4.out\" > ./lab3_test_cases/kunal_case4-dump.txt; cat lab3_test_cases/kunal_case4-dump.txt; cat lab3_test_cases/kunal_case4.out; echo \"-------------------------\" ;cat lab3_test_cases/case4.out;"

case5:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=1 --bpred_type=3  --bpred_hist_len=2 --enable_vmem=0 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=1 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/case5.pzip\" --output_file=\"./lab3_test_cases/kunal_case5.out\" > ./lab3_test_cases/kunal_case5-dump.txt; cat lab3_test_cases/kunal_case5-dump.txt; cat lab3_test_cases/kunal_case5.out; echo \"-------------------------\" ;cat lab3_test_cases/case5.out;"


case6:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=1 --bpred_type=3 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=0 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/trace.pzip\" --output_file=\"./lab3_test_cases/kunal_trace.out\" > ./lab3_test_cases/kunal_trace-dump.txt; cat lab3_test_cases/kunal_trace-dump.txt; cat lab3_test_cases/kunal_trace.out; echo \"-------------------------\"; cat lab3_test_cases/trace.out;"

case7:
	bash -c "./sim --print_inst=0 --max_inst_count=0 --max_sim_count=0 --use_bpred=1 --bpred_type=3 --enable_vmem=1 --tlb_entries=4 --vmem_page_size=4096 --print_pipe_freq=0 --perfect_dcache=0 --dcache_latency=5 --dcache_size=64 --mem_latency_row_hit=10 --mem_latency_row_miss=20 --trace_file=\"./lab3_test_cases/trace2.pzip\" --output_file=\"./lab3_test_cases/kunal_trace2.out\" > ./lab3_test_cases/kunal_trace2-dump.txt; cat lab3_test_cases/kunal_trace2-dump.txt; cat lab3_test_cases/kunal_trace2.out; echo \"-------------------------\"; cat lab3_test_cases/trace2.out;"


sim: all_knobs.o knob.o cache.o sim_main.o memory.o bpred.o vmem.o sim.h sim.cpp
	${CC} ${COMPILE_OPTION} -o sim sim.cpp all_knobs.o knob.o cache.o sim_main.o memory.o bpred.o vmem.o ${LINK_OPTION}

all_knobs.o: all_knobs.cpp all_knobs.h
	${CC} -c ${COMPILE_OPTION} all_knobs.cpp

sim_main.o: sim_main.cpp 
	${CC} -c ${COMPILE_OPTION} sim_main.cpp

knob.o: knob.cpp knob.h
	${CC} -c ${COMPILE_OPTION} knob.cpp

cache.o: cache.cpp 
	${CC} -c ${COMPILE_OPTION} cache.cpp 

memory.o: memory.cpp memory.h
	${CC} -c ${COMPILE_OPTION} memory.cpp

bpred.o: bpred.cpp bpred.h
	${CC} -c ${COMPILE_OPTION} bpred.cpp

vmem.o: vmem.cpp vmem.h
	${CC} -c ${COMPILE_OPTION} vmem.cpp
